# include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int SIZE=(1<<21)+1;
char ibuf[SIZE],*iS,*iT;
# define gc() (iS==iT && (iT=(iS=ibuf)+fread(ibuf,1,SIZE,stdin),iS==iT)?EOF:*iS++)
int read()
{
	int x=0;
	bool sgn=0;
	char ch=gc();
	for(;ch<'0' || ch>'9';ch=gc()) if(ch=='-') sgn=1;
	for(;ch>='0' && ch<='9';ch=gc()) x=x*10+ch-'0';
	return sgn?-x:x;
}
const ll INF=1e18;
int a[500010],id[500010],nd[500010],r[500010];
ll f[500010],maxn[2000010],addmk[2000010];
vector<int> vec[500010];
void build(int rt,int l,int r)
{
	maxn[rt]=-INF;
	if(l==r) return;
	int mid=(l+r)/2;
	build(rt*2,l,mid);
	build(rt*2+1,mid+1,r);
}
void update(int rt,int l,int r,int x,ll y)
{
	if(l==r) return maxn[rt]=y,void();
	int mid=(l+r)/2;
	if(x<=mid) update(rt*2,l,mid,x,y);
	else update(rt*2+1,mid+1,r,x,y);
	maxn[rt]=max(maxn[rt*2],maxn[rt*2+1]);
}
ll query(int rt,int l,int r,int x,int y)
{
	if(l>y || r<x) return -INF;
	if(l>=x && r<=y) return maxn[rt];
	int mid=(l+r)/2;
	return max(query(rt*2,l,mid,x,y),query(rt*2+1,mid+1,r,x,y));
}
int main()
{
	freopen("holiday.in","r",stdin);
	freopen("holiday.out","w",stdout);
	int n,K,D;
	n=read();K=read();D=read();
	for(int i=0,k=0;i<K;i++)
		for(int j=(i?i:K);j<=n;j+=K)
			nd[id[j]=++k]=j,r[j]=i;
	for(int i=1;i<=n;i++) a[i]=read();
	for(int i=1;i<n;i++) vec[i+read()].push_back(i);
	build(1,1,n);
	f[1]=a[1];
	for(int i=2;i<=n;i++)
	{
		update(1,1,n,id[i-1],(ll)K*f[i-1]+ll((i-1)-r[i-1])*D);
		int p=partition_point(nd+1,nd+n+1,[&](const int &x){return r[x]<=r[i];})-nd;
		f[i]=(max(query(1,1,n,1,p-1),query(1,1,n,p,n)+(ll)K*D)-ll(i-r[i])*D)/K+a[i];
		for(int j:vec[i]) update(1,1,n,id[j],-INF);
	}
	cout<<f[n]<<endl;
	fclose(stdin);
	fclose(stdout);
	return 0;
}
